package blocstac.editimage.rotate
{
import blocstac.editimage.base.StateManager;
import blocstac.editimage.base.ViewModel;

import flash.display.Bitmap;
import flash.display.Graphics;
import flash.display.Shape;
import flash.events.MouseEvent;

import spark.core.SpriteVisualElement;

public class RotateComponent extends SpriteVisualElement
{
	private var _stateManager:StateManager
	private var _viewModel:ViewModel
	private var _imageComponent:Bitmap
	private var _imageMask:Shape
	
	function RotateComponent(stateManager:StateManager, imageComponent:Bitmap) {
		_stateManager = stateManager
		_viewModel = stateManager.viewModel
		_imageComponent = imageComponent
	}
	
	public function updateUserViewScale():void {
		buttonMode = _viewModel.userViewIsScaled()
		
		if (! _imageMask) {
			_imageMask = new Shape()
			addChild(_imageMask)
			_imageComponent.mask = _imageMask
		}
		var gi:Graphics = _imageMask.graphics
		gi.clear()
		gi.beginFill(0xff0000)
		gi.drawRect(0, 0, _viewModel.imageViewWidth, _viewModel.imageViewHeight)
		gi.endFill()

		var g:Graphics = graphics
		g.clear()
		g.beginFill(0xff0000, 0)
		g.drawRect(0, 0, _viewModel.imageViewWidth, _viewModel.imageViewHeight)
		g.endFill()
	}
	
}
}